SelectMany(TSource, TCollection, TResult) Method (ParallelQuery(TSource), Func(TSource, IEnumerable(TCollection)), Func(TSource, TCollection, TResult))

Task Parallel System.Threading

Projects each element of a sequence to an IEnumerable{T}, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SelectMany(Of TSource, TCollection, TResult) ( _
	source As ParallelQuery(Of TSource), _
	collectionSelector As Func(Of TSource, IEnumerable(Of TCollection)), _
	resultSelector As Func(Of TSource, TCollection, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>(
	ParallelQuery<TSource> source,
	Func<TSource, IEnumerable<TCollection>> collectionSelector,
	Func<TSource, TCollection, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
A sequence of values to project.
collectionSelector
Type: System..::.Func<(Of <(TSource, IEnumerable<(Of <(TCollection>)>)>)>)
A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
resultSelector
Type: System..::.Func<(Of <(TSource, TCollection, TResult>)>)
A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

Type Parameters

TSource
The type of elements of source.
TCollection
The type of the intermediate elements collected by collectionSelector.
TResult

Return Value

A sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source and then mapping each of those sequence elements and their corresponding source element to a result element.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source or collectionSelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also